#include "DataStructure/Input/Element/CBUSHData.h"

#include "Utility/Algebra/Vector3D.h"

#include "DataStructure/Common/Validation.h"
using namespace SG::DataStructure;

/// @brief 来自 GA 的方位矢量在 GA 的位移坐标系中的分量
/// @return
SG::Algebra::Vector3D FEM::CBUSHData::GetXi () const
{
    return SG::Algebra::Vector3D{ m_x1, m_x2, m_x3 };
}

/// @brief OCID 坐标系中的弹簧减震器偏移量(如果 OCID > 0)
/// @return
SG::Algebra::Point FEM::CBUSHData::GetSi () const
{
    return SG::Algebra::Point{ m_s1, m_s2, m_s3 };
}

/// @brief 判断两个CBUSHData是否相等
/// @param a
/// @param b
/// @return
bool FEM::operator== (const SG::DataStructure::FEM::CBUSHData& a, const SG::DataStructure::FEM::CBUSHData& b)
{
    if (a.m_id != b.m_id)
    {
        return false;
    }
    if (a.m_pId != b.m_pId)
    {
        return false;
    }
    if (a.m_g[0] != b.m_g[0])
    {
        return false;
    }
    if (a.m_g[1] != b.m_g[1])
    {
        return false;
    }
    if (a.m_flag != b.m_flag)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_x1, b.m_x1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_x2, b.m_x2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_x3, b.m_x3))
    {
        return false;
    }
    if (a.m_go != b.m_go)
    {
        return false;
    }
    if (a.m_coordId != b.m_coordId)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_s, b.m_s))
    {
        return false;
    }
    if (a.m_oCId != b.m_oCId)
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_s1, b.m_s1))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_s2, b.m_s2))
    {
        return false;
    }
    if (!SG::DataStructure::Common::isNear (a.m_s3, b.m_s3))
    {
        return false;
    }
    if (a.m_domainId != b.m_domainId)
    {
        return false;
    }
    return true;
}